package com.payment.service.impl;

import com.payment.entity.HospitalUser;
import com.payment.mapper.HospitalUserMapper;
import com.payment.service.HospitalUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class HospitalUserServiceImpl implements HospitalUserService {

    @Resource
    private HospitalUserMapper hospitalUserMapper;

    @Override
    public List<HospitalUser> getAllUser() {
        return hospitalUserMapper.getAllUser();
    }

    @Override
    public HospitalUser getUserById(int id) {
        return hospitalUserMapper.getUserById(id);
    }

    @Override
    public HospitalUser  login(HospitalUser p) {
        return hospitalUserMapper.login(p);
    }

    @Override
    public int addUser(HospitalUser p) {
        System.out.println("servoce层");
        System.out.println(p.getJurisdiction());

        if (p.getJurisdiction()==1){
            return hospitalUserMapper.addUser(p);
        }else if (p.getJurisdiction()==2){
            return hospitalUserMapper.addAdmin(p);
        }else {
            return 0;
        }


    }

    @Override
    public int delUser(int id) {
        return hospitalUserMapper.delUser(id);
    }

    @Override
    public int editUser(HospitalUser p) {
        return hospitalUserMapper.editUser(p);
    }
}
